package com.xiaotao.http.controllers;

import com.xiaotao.http.core.annotation.WebController;
import com.xiaotao.http.core.request.HttpRequest;
import com.xiaotao.http.core.response.HttpResponse;
import com.xiaotao.http.core.interfaces.Controller;

import java.io.IOException;

/**
 * 两值相加
 */
@WebController("/api/add")
public class Add implements Controller {
    @Override
    public void service(HttpRequest request, HttpResponse response) throws IOException {
        String res;
        int a,b;
        a = Integer.parseInt(request.getParameter("a"));
        b = Integer.parseInt(request.getParameter("b"));
        res = "a = " + a;
        res += "<br>";
        res += "b = " + b;
        res += "<br>";
        res += "a + b = " + ( a + b);
        res += "<br>";
        response.setContentLength(res.length());
        response.write(res);

    }
}
